package com.example.sneakerappforme1105.fragment;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.fragment.app.Fragment;
import androidx.viewpager2.widget.ViewPager2;

import com.example.sneakerappforme1105.R;
import com.example.sneakerappforme1105.adapter.ClassPagerAdapter;
import com.google.android.material.tabs.TabLayout;
import com.google.android.material.tabs.TabLayoutMediator;

import java.time.temporal.Temporal;
import java.util.ArrayList;
import java.util.List;

public class OrderFragment extends Fragment {
    protected View mView;
    protected AppCompatActivity mActivity;  // 活动对象
    private List<String> mTitleList = new ArrayList<>(); //标题文字列表
    private  ImageView iv_back;
    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        mActivity = (AppCompatActivity) getActivity();
        mView = inflater.inflate(R.layout.fragment_order, container, false);
        TextView tv_title3  = mView.findViewById(R.id.tv_title3);
        mView.findViewById(R.id.iv_back3).setVisibility(View.GONE);
        tv_title3.setText("客户订单");
        // 设置控件
        Toolbar tl_head = mView.findViewById(R.id.tl_head);

        mTitleList.add("待处理");
        mTitleList.add("已处理");

        TabLayout tab_title = mView.findViewById(R.id.tab_title);

        ViewPager2 vp2_content = mView.findViewById(R.id.vp2_content);


        ClassPagerAdapter adapter = new ClassPagerAdapter(mActivity, mTitleList);
        vp2_content.setAdapter(adapter); // 设置二代翻页视图的适配器


        new TabLayoutMediator(tab_title, vp2_content, new TabLayoutMediator.TabConfigurationStrategy() {
            @Override
            public void onConfigureTab(@NonNull TabLayout.Tab tab, int position) {
                tab.setText(mTitleList.get(position));  // 服装、电器
            }
        }).attach();
        return mView;

    }
}

